// For error message boxes
using System.Windows.Forms;

namespace GAscheduler
{
    static class Facade
    {
        // These variables are used to check whether or not a file has been loaded.
        private static bool bCoursesLoaded = false;
        private static bool bRoomsLoaded = false;
        private static bool bPeriodsLoaded = false;
    
        public static void init()
        {
             Schedule_Manager.init();
        }

        public static void destroy()
        {
            Schedule_Manager.destroy();
        }

        public static void LoadCourses(string fileName)
        {
             CourseManager.LoadExcel(fileName);
             bCoursesLoaded = true;
        }

        public static void LoadRooms(string fileName)
        {
             RoomManager.LoadCSV(fileName);
             bRoomsLoaded = true;
        }

        public static void LoadPeriods(string fileName)
        {
             PeriodManager.LoadCSV(fileName);
             bPeriodsLoaded = true;
        }

        // Interact with the genetic algorithm code, telling it to start and stop generating schedules
        public static void start() //only start if all three files have already been loaded
        {
             if (bCoursesLoaded && bRoomsLoaded && bPeriodsLoaded)
             Schedule_Manager.continueBreeding = true;
             else
             MessageBox.Show("Error: All three files must load successfully.");
        }

        public static void stop()
        {
             Schedule_Manager.continueBreeding = false;
        }

        // Save the current best schedule as a document
        public static void save(string fileName)
        {
             Schedule_Manager.save(fileName);
        }

        // Return the current fitnesses in the genetic algorithm
        public static string fitnesses()
        {
             return Schedule_Manager.ToString();             
        }

        public static void setMutationRate(double rate)
        {
             Schedule.mutationRate = rate;
        }

        public static void setPopulation(int population)
        {
             Schedule_Manager.population = population;
        }
     }
}